
public class Message {
	public long src;
	/*
	 * Source of the message
	 */
	public long dest;
	/*
	 * destination of the message
	 */
	public int type;
	/*
	 * message types:
	 * 
	 */
	public int ttl=32;
	/*
	 * Time to live (ttl) 
	 * Will be used to avoid the loops
	 */
	public Object payload;
	public Object payload1;
	
	
	public static final int RDV_PUBLISH = 0; 	
	/*
	 * this is the packet type for publishing the "routing information"
	 * at the rendezvous points, the routing information here is simply an 
	 * object of type "Bucket"
	 */
	public static final int RDV_QUERY = 1;
	/*
	 * this is the packet type for quering the "routing information" for 
	 * certain bucket. Again we will send the Bucket object as a payload.
	 */
	
	public static final int RDV_REPLY = 2;
	/*
	 * This the reply packet in response to the RDV_QUERY packet received 
	 * by some node.
	 * e.g. if a node x queries it rendezvous point node y for some bucket
	 * bk(x), then y will send the reply packet containing payload as the 
	 * bucket that was deposited earlier by some node.
	 * If there are multiple entries then it will send multiple replies.
	 * Else it will send a bucket as payload which has -1 for all the fields.
	 */
	public static final int RDV_BRIDGE_QUERY = 3;
	
	public static final int HOPCOUNT = 4;
	
	public static final int HOPCOUNT_PATH = 5;
	
	public static final int RDV_PUBLISH_PREFIX = 6;
	/*
	 * This message type will be used for the control packets to query for
	 * bridges.
	 */
	public String getType() {
		switch(type){
			case RDV_BRIDGE_QUERY:
				return "Bridge Query";
			case RDV_PUBLISH:
				return "RDV Publish";
			case RDV_QUERY:
				return "RDV Query";
			case RDV_REPLY:
				return "RDV Reply";
			case HOPCOUNT:
				return "HOP Count";
			case RDV_PUBLISH_PREFIX:
				return "RDV_PUBLISH_PREFIX";
			case HOPCOUNT_PATH:
				return "HOPCOUNT_PATH";
			default:
				return "Unknown type";
		}
	}
	public String toString(){
		return ("From: "+src+" ["+World.toBinaryString(src) + "] \tTo: "+dest+"["+World.toBinaryString(dest)+"]\tType: "+getType()+"\nPayload: "+payload);
	}
}
